#ifndef _RETRO_DATADISPLAY
#define _RETRO_DATADISPLAY

#define SPRITENODE_SELECTED   0x00010000
#define SPRITENODE_HIDDEN     0x00020000
#define SPRITENODE_LOCKED     0x00040000

namespace Retro
{
  namespace Device
  {
    namespace Display
    {
      struct SpriteNode : Data::SpriteData
      {
        SpriteNode*   prev;
        SpriteNode*   next;
        SpriteNode*   child;
        Geom::Bounds  viewBounds;
        REAL          viewRotate;
        Texture*      texture;
      };

      DLLEXPORT BOOL DrawSpriteNode(
        DisplayDevice* iDevice,
        const SpriteNode* iNode,
        const Geom::Bounds& iDest,
        const POINT& iOffset
        );

      DLLEXPORT VOID GetSpriteNodes(
        const Data::SpriteMap* iMap,
        SpriteNode** iBuffer
        );

      DLLEXPORT VOID SetSpriteNodes(
        Data::SpriteMap* iMap,
        SpriteNode** iBuffer
        );

      DLLEXPORT INT GetSpriteChildCount(
        const Data::SpriteData* value,
        BOOL recursive
        );

      DLLEXPORT VOID  DeleteSpriteNode(
        SpriteNode* value
        );

      DLLEXPORT VOID  InitializeSpriteNodes(
        DisplayDevice* iDevice,
        SpriteNode** iBuffer,
        INT iLayers,
        const Data::RetroProject* iProject
        );

      INL VOID  FreeSpriteNodes(
        SpriteNode** iBuffer,
        INT iLayers
        )
      {
        for (int i = 0; i < iLayers; ++i)
          DeleteSpriteNode(iBuffer[i]);

        delete[] iBuffer;
      }
    } // namespace Display
  } // namespace Device
} // namespace Retro

#endif
